home *** CD-ROM | disk | FTP | other *** search
- unit MySpeechSynthesis;
-
- interface
-
- uses
- {$IFC UNDEFINED THINK_PASCAL}
- Types,
- {$ELSEC}
- InterfacesUI, {Glue for 4.0.2 without UPI!}
- {$ENDC}
- DialogUtils, Speech;
-
- procedure MyInitSpeech (sayEnabled: Boolean);
- { Speak arbitrary text, optionally sets a stat text dialog with the text }
- procedure Say (theStr: Str255;
- dontInterrupt: Boolean;
- dlg: DialogPtr;
- item: Integer);
- function MySpeechBusy: Boolean;
-
- implementation
-
- var
- gCanSpeak: Boolean;
-
- procedure MyInitSpeech;
- var
- err: OSErr;
- result: LongInt;
- begin
- gCanSpeak := false;
- err := Gestalt(gestaltSpeechAttr, result);
- if (err = noErr) then
- if BTst(result, gestaltSpeechMgrPresent) then
- gCanSpeak := true;
-
- if sayEnabled then
- Say('Speech synthesis enabled', false, nil, 0);
- end; { MyInitSpeech }
-
- procedure Say (theStr: Str255;
- dontInterrupt: Boolean;
- dlg: DialogPtr;
- item: Integer);
- var
- oe: OSErr;
- begin
- if dontInterrupt then
- while MySpeechBusy do
- ;
- if gCanSpeak then
- oe := SpeakString(theStr);
- if dlg <> nil then
- if item > 0 then
- SetTextDItem(dlg, item, theStr);
- end;
-
- function MySpeechBusy: Boolean;
- begin
- if gCanSpeak then begin
- if SpeechBusy > 0 then
- MySpeechBusy := true
- else
- MySpeechBusy := false;
- end
- else
- MySpeechBusy := false;
- end;
-
-
- end.